﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;

// This file is no more useful
namespace XNADota.ContentPipeline.Terrain
{
    [ContentSerializerRuntimeType("XNADota.Terrain.Modification, XNADota")]
    public class ModificationContent
    {
        public ModificationContent(WCLoader Loader)
        {
            ModificationId = Loader.ReadString(4); 
            VariableType = Loader.ReadInt32();
//            Data = Loader.ReadString(4); 
            switch (VariableType)
            { 
                case 0:
                    Loader.ReadInt32();
                    break;
                case 1:
                    Loader.ReadFloat();
                    break;
                case 2:
                    Loader.ReadFloat();
                    break;
                case 3:
                    string content = "";
                    while (true)
                    {
                        string extra = Loader.ReadString(1);
                        content = content + extra;
                        if (extra == "")
                            break;
                    }
                    break;  
            }
            ObjectId = Loader.ReadString(4);
        }

        public string ModificationId;
        public int VariableType;
        public string ObjectId;
    }

    [ContentSerializerRuntimeType("XNADota.Terrain.CustomUnit, XNADota")]
    public class CustomUnitContent
    {
        public CustomUnitContent(WCLoader Loader)
        {
            OriginalObjectId = Loader.ReadString(4);
            ChangedObjectId = Loader.ReadString(4);
            ModifiedCount = Loader.ReadInt32();
            Modifications = new ModificationContent[ModifiedCount];
            for (int i = 0; i < ModifiedCount; i++)
                Modifications[i] = new ModificationContent(Loader);
        }

        public string OriginalObjectId;
        public string ChangedObjectId;
        public int ModifiedCount;
        public ModificationContent[] Modifications;
    }

    [ContentSerializerRuntimeType("XNADota.Terrain.CustomUnitTable, XNADota")]
    public class CustomUnitTableContent
    {
        public CustomUnitTableContent(WCLoader Loader)
        {
            UnitCount = Loader.ReadInt32();
            CustomUnits = new CustomUnitContent[UnitCount];
            for (int i = 0; i < UnitCount; i++)
                CustomUnits[i] = new CustomUnitContent(Loader);
        }

        public int UnitCount;
        public CustomUnitContent[] CustomUnits;
    }

    [ContentSerializerRuntimeType("XNADota.Terrain.WarCraftCustomUnit, XNADota")]
    public class WarCraftCustomUnitContent
    {
        public WarCraftCustomUnitContent(WCLoader Loader)
        {
            Version = Loader.ReadInt32();
            OriginalTable = new CustomUnitTableContent(Loader);
            ChangedTable = new CustomUnitTableContent(Loader);
        }

        public int Version;
        public CustomUnitTableContent OriginalTable;
        public CustomUnitTableContent ChangedTable;
    }
}
